<template>
  <div>
    <MyHeader :background="'blue'" title="TabBar案例"></MyHeader>
    <!-- 组件 -->
    <div class="main">
      <!-- 一级路由出口 -->
      <router-view></router-view>
    </div>
    <!-- 传数组值           子向父 -->
    <MyTabBar :list="tabList" @component="Fn"></MyTabBar>
  </div>
</template>

<script>
import MyHeader from "./components/MyHeader";
import MyTabBar from "./components/MyTabBar.vue";
import MyGoodsList from "./views/MyGoodsList.vue";
import MyGoodsSearch from "./views/MyGoodsSearch.vue";
import MyUserInfo from "./views/MyUserInfo.vue";
export default {
  components: {
    MyTabBar,
    MyHeader,
    MyGoodsList,
    MyGoodsSearch,
    MyUserInfo,
  },
  data() {
    return {
      // 设置初始默认值   用来开页面渲染
      tabList: [
        {
          iconText: "icon-shangpinliebiao",
          text: "商品列表",
          componentName: "MyGoodsList",
        },
        {
          iconText: "icon-sousuo",
          text: "商品搜索",
          componentName: "MyGoodsSearch",
        },
        {
          iconText: "icon-user",
          text: "我的信息",
          componentName: "MyUserInfo",
        },
      ],
    };
  },
  // 接受传来的数 进行赋值
  // 用编程式导航进行传参  加入路由路径
  methods: {
    Fn(component) {
      this.$router.push({
        path: component,
      });
    },
  },

  // // 用来首次开页面进行渲染
  // created() {
  //   this.$router.push({
  //     path: this.names,
  //   });
  // },
};
</script>

<style scoped>
.main {
  padding-top: 45px;
  padding-bottom: 51px;
}
</style>